'''
Created on Mar 13, 2012

@author: wilshusensk
'''
class classificationAndWordsForSite(object):
    def __init__ (self, classification, words):
        self.form = (classification, words)
    
    def getClassification(self):
        return self.form[0]

    def getWords(self):
        return self.form[1]
    
class carry_on_d(object):
    def __init__ (self):
        self.form = {}
        
    #self.form will have:
        #keys that are the websites
        #values that are the classification along with the words
    def getForm(self):
        return self.form
    
    def add(self, site, words):
        self.form[site] = words
    
    def printValues(self):
        thislist = self.form.values()
        for i in range(0, len(self.form.keys())):
            curlist = thislist[i]
            for j in range(0, len(curlist)):
                #print(curlist[j])
                if j > 5:
                    break
            print("Done with one\n\n")

    #Check search terms for the constellations

    def correlatePagesToConstellation(self, constellations):
        print("Got here")
        classifications = []
        keys = self.form.keys()
        numberOfSites = len(self.form.keys())
        for i in range(numberOfSites):
            currentSite = keys[i]
            currentWords = self.form[currentSite]
            #print(currentWords)
            #print("cur site is ")
            #print(currentSite)
            
            countOfConstellationOccurances = {}
            for j in constellations:
                countOfConstellationOccurances[j] = 0
            for curConstellation in constellations:
                curConstellation = curConstellation.strip()
                brokenConstellation = curConstellation.split("_")
                for siteWord in currentWords:
                    for constellationWord in brokenConstellation:
                        if siteWord.lower() == constellationWord.lower():
                            countOfConstellationOccurances[curConstellation] += 1
            inverse = [(value, key) for key, value in countOfConstellationOccurances.items()]
            TheMax = max(inverse)
            if TheMax[0] > 0:
                print TheMax[1]
                classifications.append( ( TheMax[1], currentSite, currentWords ) )
        return classifications